﻿using System;

namespace System
{
    /// <summary>Месяцы года</summary>
    [Serializable]
    public enum Month
    {
        /// <summary>Январь</summary>
        January = 1,
        /// <summary>Февраль</summary>
        February = 2,
        /// <summary>Март</summary>
        March = 3,
        /// <summary>Апрель</summary>
        April = 4,
        /// <summary>Май</summary>
        May = 5,
        /// <summary>Июнь</summary>
        June = 6,
        /// <summary>Июль</summary>
        July = 7,
        /// <summary>Август</summary>
        August = 8,
        /// <summary>Сентябрь</summary>
        September = 9,
        /// <summary>Октябрь</summary>
        October = 10,
        /// <summary>Ноябрь</summary>
        November = 11,
        /// <summary>Декабрь</summary>
        December = 12
    }


}

namespace MathService.Date
{
    public static class Week
    {
        public static DayOfWeek Compute(int Day, Month Month, int Year)
        {
        return Compute(Day, (int)Month, Year);
        }

        public static DayOfWeek Compute(int Day, int Month, int Year)
        {
            //if(Month > 12)
            //    throw new ArgumentOutOfRangeException("Номер месяца вне диапазона [1..12]");
            //bool LeapYear = Year.IsDevidedTo(400) || (Year.IsDevidedTo(4) && !Year.IsDevidedTo(100));
            var a = (14 - Month) / 12;
            var y = Year - a;
            var m = Month + 12 * a - 2;
            var w = (7000 + (Day + y + y / 4 - y / 100 + y / 400 + (31 * m) / 12)) % 7;
            return (DayOfWeek)w;
        }
    }
}
